import React,{useEffect,useState} from 'react';
import {
    SafeAreaView,
    StyleSheet,
    ScrollView,
    View,
    Text,
    DeviceEventEmitter, TextInput, Linking,
} from 'react-native';
import Header from '../../widgets/Header';


export default ({navigation})=>{

    const {weburl,callback} = navigation.state.params
    useEffect(()=>{

        return ()=>{
            console.log('rechargeSub unmount')
            callback && callback()
        }
    },[])

    const onShouldStartLoadWithRequest = (request)=>{
        if(!request.url.startsWith('http'))
        {
            Linking.openURL(request.url).catch(er => {
                console.log("Failed to open Link: " + er.message);
            });
            return false;
        }
        return true;
    }

    return (
        <View style={styles.container}>
            <Header title={'Recharge in Progress'} navigation={navigation}/>
          {/*  <WebView
                originWhitelist={['*']}
                allowFileAccess={true}
                disableTouchHideKeyboard={true}
                source={{uri:weburl}}
                startInLoadingState={true}
                onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
            />*/}



        </View>
    )
}

const styles= StyleSheet.create({
    container:{
        flex:1
    }
})
